<template>

  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a  v-on:click.prevent="handleInfo"  ><a @click="handleEdit(record)"> 新增方案</a>
      </a>
<!--      <a-button type="primary" icon="download" @click="handleExportXls('ytsj_jdjcxx')">导出</a-button>-->
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <!-- 高级查询区域 -->
<!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
    </div>
<!--    <div>-->
<!--      <YtsjYlFnList></YtsjYlFnList>-->
<!--    </div>-->

    <!-- table区域-begin -->
    <div v-show="false">
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="jingId"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a  v-on:click.prevent="handleInfo"  ><a @click="handleEdit(record)"> 生成方案</a>
          </a>
          <a-divider type="vertical" />
          <a> 查看方案</a>

            <a-divider type="vertical" />

            <a v-on:click="handlepanduan" @click="handleEdit(record)" >编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <ytsj-jdjcxx-modal  v-show="this.panduan" ref="modalForm" @ok="modalFormOk" :chuandangqianjingid="chuandangqianjingid"></ytsj-jdjcxx-modal>
    <a-modal
      destroyOnClose="true"
      :width="1800"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      footer=""
      :maskClosable="false"
      :afterClose="afterClose"




    >
      <a-spin :spinning="false">
        <fieldset>
          <a-form-model ref="form1" :model="model1" :rules="validatorRules1">
            <a-row>
              <a-col :span="24">
              <StepForm :shuaxing="shuaxing"  ></StepForm>
              </a-col>
            </a-row>
          </a-form-model>
        </fieldset>
      </a-spin>
    </a-modal>
  </a-card>

</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import YtsjJdjcxxModal from './modules/YtsjJdjcxxModal'
  import StepForm from "./modules/StepForm";
  import bus from "./modules/bus";
  import {axios} from "../../../utils/request";


  export default {
    name: 'YtsjJdjcxxList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      YtsjJdjcxxModal,
       StepForm,


    },
    data () {
      return {


          shuaxing:true,
          panduan: true,

        description: 'ytsj_jdjcxx管理页面',
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // },
          {
            title:'井id号',
            align:"center",
            dataIndex: 'jingId'
          },
          {
            title:'地理位置',
            align:"center",
            dataIndex: 'dlwz'
          },
          {
            title:'构造位置',
            align:"center",
            dataIndex: 'gzwz'
          },
          {
            title:'地面海拔',
            align:"center",
            dataIndex: 'dmhb'
          },
          {
            title:'开钻日期',
            align:"center",
            dataIndex: 'kzrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'完钻井深',
            align:"center",
            dataIndex: 'wzjs'
          },
          {
            title:'人工井底',
            align:"center",
            dataIndex: 'rgjd'
          },
          {
            title:'最大井斜',
            align:"center",
            dataIndex: 'zdjx'
          },
          {
            title:'油层套管清水控制压力',
            align:"center",
            dataIndex: 'yctgqskzyl'
          },
          {
            title:'补心海拔',
            align:"center",
            dataIndex: 'bxhb'
          },
          {
            title:'完钻日期',
            align:"center",
            dataIndex: 'wzrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'完钻层位',
            align:"center",
            dataIndex: 'wzcw'
          },
          {
            title:'完井方法',
            align:"center",
            dataIndex: 'wjff'
          },
          {
            title:'最大井斜处井深',
            align:"center",
            dataIndex: 'zdjxcjs'
          },
          {
            title:'压裂井口',
            align:"center",
            dataIndex: 'yljk'
          },
          {
            title:'井名',
            align:"center",
            dataIndex: 'jingName'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/jdjcxx/ytsjJdjcxx/list",
          delete: "/jdjcxx/ytsjJdjcxx/delete",
          deleteBatch: "/jdjcxx/ytsjJdjcxx/deleteBatch",
          exportXlsUrl: "/jdjcxx/ytsjJdjcxx/exportXls",
          importExcelUrl: "jdjcxx/ytsjJdjcxx/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],

          visible:false,
          model1:{},
          validatorRules1: {
          },
          labelCol: {
              xs: { span: 24 },
              sm: { span: 8 },
          },
          wrapperCol: {
              xs: { span: 24 },
              sm: { span: 16 },
          },
          queryParam:{ppjzsbId:null},
      }
    },
    created() {

        localStorage.removeItem('jingId');
        this.handleEdit(record);
    this.getSuperFieldList();
    },
    computed: {
        totel1: function(){

        },
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
        afterClose(){
            this.$confirm({
                title: '想要保存当前数据吗?',
                content: '',
                onOk() {
                     console.log("已经调用了"+localStorage.getItem("jingId"))
                    console.log("已经调用了"+localStorage.getItem("dqjdqqgzqk"))
                    console.log("已经调用了"+localStorage.getItem("ljdsgqk"))
                    console.log("已经调用了"+localStorage.getItem("zljjl")+"hahahahaha")


                    axios.post('/YtsjWz/ytsjWz/add',{fanganId:localStorage.getItem("jingId"),qqgzqk:localStorage.getItem("dqjdqqgzqk"),ljzldb:localStorage.getItem("ljzldb"),
                       ljsgqk:localStorage.getItem("ljdsgqk"), ljsgxgjscqk:localStorage.getItem("ljsgxgjscqk"), ljdbjl:localStorage.getItem("ljzldb"),dndhlstx:localStorage.getItem("dndhlstx"),
                       zndhlstx:localStorage.getItem("zndhlstx"),sytx:localStorage.getItem("sytx"),pfsjly:localStorage.getItem("pfsjly"),sggmjcs:localStorage.getItem("zljjl"),
                       pyszyqjsbyq:localStorage.getItem("szyqjpysb"),ytxcpzcx:localStorage.getItem("ytxcpzcx"),anquan:localStorage.getItem("anquan"),huanbao:localStorage.getItem("huanbao")
                   })
                    return new Promise((resolve, reject) => {
                        setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);

                    }).catch(() => console.log('Oops errors!'));
                },
                onCancel() {},
            });
            //  console.log("已经调用了"+localStorage.getItem("jingId"))
            // this.$http.post('/YtsjWz/ytsjWz/add',{fanganId:localStorage.getItem("jingId")})
        },
        handlepanduan(){
            this.panduan = true;
        },

        handleOk(){
            console.log(this.model1);
            this.model1.id = ''
            var d = {}
            // d.serialNo = this.model1.controlDeviceId
            // d.actoin='setMode'
            // d.data = {'volume':this.model1.fillingVolumeDay,'mixingTimeSpace':this.model1.mixingInterval,'mixingTimeLength':this.model1.mixingTime}
            // console.log(d);
            // httpAction('/PIData',d).then(r=>{
            //   if(res.code === 1){
            //     httpAction('/jzzdls/ppgyJzzdls/add',this.model1,'post').then((res)=>{
            //       if(res.success){
            //         this.$message.success(res.message);
            //         this.$emit('ok');
            //         this.visible = false
            //       }else{
            //         this.$message.warning(res.message);
            //       }
            //     })
            //   }
            // })
            // httpAction('/jzzdls/ppgyJzzdls/add',this.model1,'post').then((res)=>{
            //     if(res.success){
            //         this.$message.success(res.message);
            //         this.$emit('ok');
            //         this.visible = false
            //     }else{
            //         this.$message.warning(res.message);
            //     }
            // })
        },
        chuandangqianjingid(record){
                 console.log(record)
            this.record = record;
        },
        handleCancel () {


            this.visible = false


        },
        getQueryList(id){
            console.log(id);
            this.queryParam.ppjzsbId = id

            setTimeout(() => {
                this.searchQuery()
            }, 100);
        },
        handleInfo(record){

            this.$store.state.shuaxing = false;
            console.log(record);
            this.visible = true;
            this.model1 = Object.assign({}, record);
            this.panduan = false;
            localStorage.setItem("panduan",this.panduan)

        },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'jingId',text:'井id号'})
        fieldList.push({type:'string',value:'dlwz',text:'地理位置'})
        fieldList.push({type:'string',value:'gzwz',text:'构造位置'})
        fieldList.push({type:'string',value:'dmhb',text:'地面海拔'})
        fieldList.push({type:'date',value:'kzrq',text:'开钻日期'})
        fieldList.push({type:'string',value:'wzjs',text:'完钻井深'})
        fieldList.push({type:'string',value:'rgjd',text:'人工井底'})
        fieldList.push({type:'string',value:'zdjx',text:'最大井斜'})
        fieldList.push({type:'string',value:'yctgqskzyl',text:'油层套管清水控制压力'})
        fieldList.push({type:'string',value:'bxhb',text:'补心海拔'})
        fieldList.push({type:'date',value:'wzrq',text:'完钻日期'})
        fieldList.push({type:'string',value:'wzcw',text:'完钻层位'})
        fieldList.push({type:'string',value:'wjff',text:'完井方法'})
        fieldList.push({type:'string',value:'zdjxcjs',text:'最大井斜处井深'})
        fieldList.push({type:'string',value:'yljk',text:'压裂井口'})
        fieldList.push({type:'string',value:'jingName',text:'jingName'})
        this.superFieldList = fieldList
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>